package com.tran.demo.advice;

import java.time.LocalDateTime;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tran.demo.aspect.MyAspect;
import com.tran.demo.enums.ResultEnum;
import com.tran.demo.exception.MyException;

@ControllerAdvice
@ResponseBody
public class MyAdvice {
	
	private Logger log = LoggerFactory.getLogger(MyAdvice.class);

	//声明要捕获的异常
	@ExceptionHandler(MyException.class)
	public Object defultExcepitonHandler(HttpServletRequest request,Exception e) {
		log.info("进入增强异常处理:{}",LocalDateTime.now());
		log.info("异常信息：{}",e.getMessage());
		return e.getMessage();
	}
}
